package paquete;

import java.io.IOException;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import com.sun.lwuit.Button;
import com.sun.lwuit.CheckBox;
import com.sun.lwuit.Command;
import com.sun.lwuit.Container;
import com.sun.lwuit.Dialog;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;

public class OrderCloseTwo extends MIDlet  implements ActionListener{
	
	private static final String LWUIT_RESOURCE_FILE = "/SmartSupport.res";
	private static final String LWUIT_THEME = "SmartSupport";
	private Form testForm; // Variable para el form
	private Command exitCommand = new Command("Exit"); // agregando un comando
														// de salida
	
	private Button buttonPagOne;
	private Button buttonPagTwo;
	private CheckBox checkBox1;
	private CheckBox checkBox2;
	private CheckBox checkBox3;
	private CheckBox checkBox4;
	private CheckBox checkBox5;
	private CheckBox checkBox6;
	private CheckBox checkBox8;
	private CheckBox checkBox9;

	public OrderCloseTwo() {
		// TODO Auto-generated constructor stub
		Display.init(this);
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		// TODO Auto-generated method stub
		
		Resources lwuitResource;
		
		try {
			lwuitResource = Resources.open(LWUIT_RESOURCE_FILE);
			UIManager.getInstance().setThemeProps(
					lwuitResource.getTheme(LWUIT_THEME));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//INICIAMOS EL FORM
		// DEBEMOS SETEAR CADA UNO DE LOS COMPONETES QUE VAMOS A AGREGAR...
		this.setTestForm(new Form("Ver hora de Ruta"));
		this.setCheckBox1(new CheckBox("ACOPLE"));
		this.setCheckBox2(new CheckBox("ACRILICO DE ROTULO"));
		this.setCheckBox3(new CheckBox("AGARRADERA"));
		this.setCheckBox4(new CheckBox("AISLAMIENTO"));
		this.setCheckBox5(new CheckBox("ARRANCADORES"));
		this.setCheckBox6(new CheckBox("ASPAS"));
		this.setCheckBox8(new CheckBox("BALASTRO"));
		this.setCheckBox9(new CheckBox("BASES"));
		this.setButtonPagOne(new Button("<-Pag 1"));
		this.setButtonPagTwo(new Button("Pag. 3 ->"));
		
		
		// COMENZAMOS CON LAS CAJAS QUE VAN A CONTENER LOS CONTENEDORES YA SEA EN FORMA VERTICAL U HORIZONTAL
		
		BoxLayout boxLayoutCenter = new BoxLayout(BoxLayout.Y_AXIS); // CONTENEDOR RAIZ
		BoxLayout boxLayoutCheckBox = new BoxLayout(BoxLayout.Y_AXIS); // CONTENEDOR QUE VA A TENER LA LISTA DE CHECBOX EN FORMA VERTICAL
		BoxLayout boxLayoutButtom = new BoxLayout(BoxLayout.X_AXIS); // CONTENEDOR QUE VA A TENER LOS BOTONES EN FORMA HORIZONTAL
		
		Container containerCheckBox = new Container(); // CREAMOS EL CONTENEDOR PARA LOS CHECKBOX
		Container containerButtom = new Container();  // CREAMOS EL CONTENEDOR PARA LOS BOTONES
		Container containerCenter = new Container();  // CREAMOS EL CONTENEDOR PRINCIPAL DONDE SE ALBERGAN LOS OTROS DOS CONTENEDORES
		
		containerCheckBox.setLayout(boxLayoutCheckBox); // AGREGAMOS LA CAJA AL CONTENEDOR DE CHECKBOX
		containerCheckBox.addComponent(this.getCheckBox1());  
		containerCheckBox.addComponent(this.getCheckBox2());
		containerCheckBox.addComponent(this.getCheckBox3());
		containerCheckBox.addComponent(this.getCheckBox4());
		containerCheckBox.addComponent(this.getCheckBox5());
		containerCheckBox.addComponent(this.getCheckBox6());
		containerCheckBox.addComponent(this.getCheckBox8());
		containerCheckBox.addComponent(this.getCheckBox9());
		
		
		containerButtom.setLayout(boxLayoutButtom); // AGREGAMOS LA CAJA AL CONTENEDOR DE BUTTONS
		containerButtom.addComponent(this.getButtonPagOne());
		containerButtom.addComponent(this.getButtonPagTwo());
		
		
		containerCenter.setLayout(boxLayoutCenter); // AGREGACONS LA CAJA CENTRAL QUE VA IR VERTICA
		containerCenter.addComponent(new Label("Partes que faltaron")); // AGREGAMOS UNA ETIQUETA
		containerCenter.addComponent(containerCheckBox); // AGREGAMOS EL CONTENEDOR DE CHECKBOXS
		containerCenter.addComponent(containerButtom); // AGRAGAMOS EL CONTENEDOR DE BOTONES
		
		
		
		this.getTestForm().setLayout(new BorderLayout());
		this.getTestForm().addComponent(BorderLayout.CENTER, containerCenter);
		this.getTestForm().addCommand(this.getExitCommand());
		
		//containerCenter.addComponent(this.getListOrden());
		
		// setting components listeners
		this.getTestForm().addCommandListener(this);
		this.getButtonPagOne().addActionListener(this);
		this.getButtonPagTwo().addActionListener(this);
		this.getTestForm().setTransitionInAnimator(
				CommonTransitions.createSlide(
						CommonTransitions.SLIDE_VERTICAL, true, 1000));
		
		this.getTestForm().show();

	}

	public void actionPerformed(ActionEvent event) {
		// TODO Auto-generated method stub
		
		if (event.getCommand() == this.getExitCommand()) {
			notifyDestroyed();
		}
		else if(event.getComponent() == this.getButtonPagOne())
		{
			 Dialog.show("INFORMACION", "USTED REGRESARA A LA VENTANA 1", 2, null, "OK", null); // CODIGO PARA REGRESAR AL FORMULARIO PAG1
		}
		else if(event.getComponent() == this.getButtonPagTwo())
		{
			 Dialog.show("INFORMACION", "USTED IRA A LA VENTANA 3", 2, null, "OK", null); // CODIGO PARA IR A LA PAGINA 2
				
			
		}
		
	}

	public Form getTestForm() {
		return testForm;
	}

	public void setTestForm(Form testForm) {
		this.testForm = testForm;
	}

	public Command getExitCommand() {
		return exitCommand;
	}

	public void setExitCommand(Command exitCommand) {
		this.exitCommand = exitCommand;
	}

	public Button getButtonPagOne() {
		return buttonPagOne;
	}

	public void setButtonPagOne(Button buttonPagOne) {
		this.buttonPagOne = buttonPagOne;
	}

	public Button getButtonPagTwo() {
		return buttonPagTwo;
	}

	public void setButtonPagTwo(Button buttonPagTwo) {
		this.buttonPagTwo = buttonPagTwo;
	}

	public CheckBox getCheckBox1() {
		return checkBox1;
	}

	public void setCheckBox1(CheckBox checkBox1) {
		this.checkBox1 = checkBox1;
	}

	public CheckBox getCheckBox2() {
		return checkBox2;
	}

	public void setCheckBox2(CheckBox checkBox2) {
		this.checkBox2 = checkBox2;
	}

	public CheckBox getCheckBox3() {
		return checkBox3;
	}

	public void setCheckBox3(CheckBox checkBox3) {
		this.checkBox3 = checkBox3;
	}

	public CheckBox getCheckBox4() {
		return checkBox4;
	}

	public void setCheckBox4(CheckBox checkBox4) {
		this.checkBox4 = checkBox4;
	}

	public CheckBox getCheckBox5() {
		return checkBox5;
	}

	public void setCheckBox5(CheckBox checkBox5) {
		this.checkBox5 = checkBox5;
	}

	public CheckBox getCheckBox6() {
		return checkBox6;
	}

	public void setCheckBox6(CheckBox checkBox6) {
		this.checkBox6 = checkBox6;
	}

	public CheckBox getCheckBox8() {
		return checkBox8;
	}

	public void setCheckBox8(CheckBox checkBox8) {
		this.checkBox8 = checkBox8;
	}

	public CheckBox getCheckBox9() {
		return checkBox9;
	}

	public void setCheckBox9(CheckBox checkBox9) {
		this.checkBox9 = checkBox9;
	}

	
}
